home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga News 95
/
Amiga News 95.iso
/
dpat
/
dpat62
/
chipmemfirst
/
chipmemfirst.asm
< prev
next >
Wrap
Assembly Source File
|
1994-05-12
|
14KB
|
689 lines
********************
* ChipMemFirst.asm *
********************
COMMENT /
ChipMemfirst a été assemblé avec le Macro68 © DigiSoft.
Pour assembler avec un autre assembleur, il suffit de changer les directives
propres au Macro68 (voir la fin du source pour de plus amples informations).
L'installation du code résident est basée sur celle de NTSC-PAL © Nico
Francois (Fish 331).
/
MC68000
EXEOBJ
OBJFILE ChipMemFirst
STRICT
NEWSYNTAX
MULTIPASS
ESCAPESTR
; VERBOSEOPTIM
INCPATH includes:
MACFILE libmacs.i
INTUITION_ERROR EQU 0
DOS_ERROR EQU 1
ICON_ERROR EQU 2
MSG_ALREADY EQU 3
MSG_NOMEM EQU 4
MSG_INSTALLED EQU 5
MSG_NOINSTALLED EQU 6
MSG_REMOVED EQU 7
MSG_NOFASTRAM EQU 8
MSG_INVALIDE EQU 9
MSG_INFERIOR EQU 10
STRUCTURE LocaleInfo,0
APTR li_LocaleBase
APTR li_Catalog
LABEL LocaleInfo_SIZEOF
_LVOOpenCatalogA EQU -150
_LVOCloseCatalog EQU -36
_LVOGetCatalogStr EQU -72
pushm MACRO
reglist setrl \1
movem.l reglist,-(SP)
ENDM
popm MACRO
movem.l (SP)+,reglist
ENDM
MESSAGE MACRO
IFC 'locale',\1
moveq #\2,d0
lea (localeinfo),a0
bsr.w GetString
movea.l d0,a0
ELSE
lea (\1.msg),a0
ENDC
tst.b (fromWB)
beq.b fromCLI\@
lea (myRequest),a1
move.l a0,(es_TextFormat,a1)
suba.l a0,a0
movea.l a0,a2
movea.l a0,a3
move.l (_IntuitionBase),d0
beq.b endMess\@
movea.l d0,a6
CALL EasyRequestArgs
bra.b endMess\@
fromCLI\@
move.l a0,d1
move.l (_DOSBase),d0
beq.b endMess\@
movea.l d0,a6
CALL PutStr
endMess\@
ENDM
_custom EQU $dff000
MAXPRI EQU 60
;VERSION_2_0 EQU 37
SECTION ChipMemFirst,CODE
include mystartup.i
moveq #RETURN_FAIL,d7
lea (LocaleName),a1
moveq #0,d0
CALL OpenLibrary
move.l d0,(_LocaleBase)
beq.w noLocale
movea.l d0,a6
suba.l a0,a0
movea.l a0,a2
lea (CatalogName),a1
CALL OpenCatalogA
lea (localeinfo),a0
move.l a6,(a0)+
move.l d0,(a0)
lea (IntuitionName),a1
moveq #37,d0
CALL _SysBase,OpenLibrary
move.l d0,(_IntuitionBase)
beq.w noInt
lea (DosName),a1
moveq #37,d0
CALL OpenLibrary
move.l d0,(_DOSBase)
beq.w noDOS
lea (IconName),a1
moveq #37,d0
CALL OpenLibrary
move.l d0,(_IconBase)
beq.w noIcon
lea (MemList,a6),a0
lea (FastRAM.txt),a1
CALL FindName
bne.b FastRamExist
MESSAGE <locale>,MSG_NOFASTRAM
bra.w Exit
FastRamExist moveq #0,d6
movea.l d0,a0
move.b (LN_PRI,a0),d6
tst.b (fromWB)
beq.w CLIStart
bra.w Remove
WBInstall bsr.w ReadWBArgs
move.l (rdargs.pri),d0
beq.w Defaut
movea.l d0,a0
lea (newpri),a1
bsr.w DecString2Long
move.l (a1),d0
bne.b ValidePri
MESSAGE <locale>,MSG_INVALIDE
bra.w Exit
ValidePri cmp.l d6,d0
bgt.b OK
MESSAGE <locale>,MSG_INFERIOR
bra.w Exit
OK cmpi.l #MAXPRI,d0
bhi.b Defaut
move.b d0,(defautpri)
Defaut bra.w Install
CLIStart MESSAGE hello
move.l #template,d1
move.l #rdargs.install,d2
moveq #0,d3
CALL _DOSBase,ReadArgs
move.l d0,(rdargs)
bne.b ArgOk
tst.l (rdargs.remove)
bne.w Remove
MESSAGE <locale>,MSG_INVALIDE
tst.l (rdargs.install)
bne.w Quit
bra.w Help
ArgOk tst.l (rdargs.help)
beq.b noHelp
bra.w Help
noHelp tst.l (rdargs.remove)
bne.w Remove
tst.l (rdargs.pri)
beq.b nopri
movea.l (rdargs.pri),a0
move.l (a0),d0
cmp.l d6,d0
bgt.b priOK
MESSAGE <locale>,MSG_INFERIOR
tst.l (rdargs.install)
bne.b Quit
bra.b Help
priOK cmpi.l #MAXPRI,d0
bhi.b nopri
move.b d0,(defautpri)
nopri tst.l (rdargs.install)
bne.w Install
Help MESSAGE usage
Quit move.l (rdargs),d1
beq.b Exit
CALL _DOSBase,FreeArgs
Exit movea.l (_IconBase),a1
CALL _SysBase,CloseLibrary
movea.l (_DOSBase),a1
CALL CloseLibrary
movea.l (_IntuitionBase),a1
CALL CloseLibrary
lea (localeinfo),a0
movea.l (a0)+,a6
movea.l (a0),a0
CALL CloseCatalog
movea.l a6,a1
CALL _SysBase,CloseLibrary
moveq #0,d0
rts
noIcon MESSAGE <locale>,ICON_ERROR
movea.l (_DOSBase),a1
CALL _SysBase,CloseLibrary
;-------------- Big problème si cette partie est exécutée sous
;-------------- Kickstart V37 et +.
;\\\\\\\\\\\\\\
noDOS MESSAGE <locale>,DOS_ERROR
movea.l (_IntuitionBase),a1
CALL _SysBase,CloseLibrary
noInt MESSAGE <locale>,INTUITION_ERROR
lea (localeinfo),a0
movea.l (a0)+,a6
movea.l (a0),a0
CALL CloseCatalog
movea.l a6,a1
CALL _SysBase,CloseLibrary
;\\\\\\\\\\\\\\
noLocale move.l d7,d0
rts
;--------------
GetString
lea (CatCompBlock),a1
bra.b 2$
1$: move.w (a1)+,d1
adda.w d1,a1
2$: cmp.l (a1)+,d0
bne.b 1$
addq.l #2,a1
move.l (a0)+,d1
bne.b 3$
move.l a1,d0
rts
3$: move.l a6,-(SP)
movea.l d1,a6
movea.l (a0),a0
CALL GetCatalogStr
movea.l (SP)+,a6
rts
;--------------
ReadWBArgs
pushm d2/a2-a3
movea.l (_WBMsg),a0
movea.l (sm_ArgList,a0),a2
move.l (wa_Lock,a2),d1
CALL _DOSBase,CurrentDir
move.l d0,d2
movea.l (wa_Name,a2),a0
CALL _IconBase,GetDiskObject
tst.l d0
beq.b .noTools
movea.l d0,a0
movea.l a0,a2
movea.l (do_ToolTypes,a0),a0
lea (ToolPri.txt),a1
CALL FindToolType
tst.l d0
beq.b .noPri
movea.l d0,a0
lea (DecBuffer),a1
movea.l a1,a3
.. move.b (a0)+,(a1)+
bne.b ..
move.l a3,(rdargs.pri)
.noPri movea.l a2,a0
CALL FreeDiskObject
.noTools move.l d2,d1
CALL _DOSBase,CurrentDir
popm
rts
;-------------- a1: en entrée, pointeur sur le nombre décimal à obtenir
;-------------- a0: en entrée, pointeur sur la chaine à convertir
;-------------- a1: en sortie, contient soit un décimal valide ou 0
DecString2Long
pushm d2-d3
moveq #0,d0
move.l d0,d1
move.l d0,d3
cmpi.b #'+',(a0)
beq.b .sign
cmpi.b #'-',(a0)
bne.b .nosign
moveq #1,d3
.sign addq.w #1,a0
.nosign
.loop move.b (a0)+,d0
beq.b .OK
subi.b #'0',d0
blt.b .nonumber
cmpi.b #9,d0
bgt.b .nonumber
move.l d1,d2
asl.l #2,d1 ;\
add.l d2,d1 ; 10 * d1
add.l d1,d1 ;/
tst.b d3
bne.b .negative
add.l d0,d1
bra.b .loop
.negative sub.l d0,d1
bra.b .loop
.nonumber clr.l (a1)
bra.b .END
.OK move.l d1,(a1)
.END popm
rts
;--------------
Install
lea (PortName,pc),a1
CALL _SysBase,FindPort
tst.l d0
beq.b Alloc
MESSAGE <locale>,MSG_ALREADY
bra.w Quit
Alloc movea.l (_SysBase),a6
moveq #256-ResidentLen,d0
neg.b d0
;-------------- Romtag possible en fast MEM à partir de l'OS 2.0
;-------------- mais doit résister à un RESET (mémoire sur carte-mère)
; move.w (LIB_VERSION,a6),d2
; cmp.w #VERSION_2_0,d2
; bcs.b .noOS2
move.l #MEMF_LOCAL,d1
; bra.b .OS2
;.noOS2 move.l #MEMF_CHIP,d1
.OS2 CALL AllocMem
tst.l d0
bne.b MemOk
MESSAGE <locale>,MSG_NOMEM
bra.w Quit
MemOk movea.l d0,a5
lea (ResidentBlock,pc),a0
movea.l d0,a1
moveq #256-ResidentLen,d0
neg.b d0
CALL CopyMem
;-------------- Macro DISABLE
; move.w #INTF_INTEN,(_custom+intena)
; addq.b #1,(IDNestCnt,a6)
CALL Disable
lea (RomTagPtrs-ResidentBlock,a5),a0
move.l (KickTagPtr,a6),(4,a0)
beq.b .noTag
bset #7,(4,a0)
.noTag move.l a0,(KickTagPtr,a6)
lea (RomTag-ResidentBlock,a5),a1
move.l a1,(a0)
lea (myMemList-ResidentBlock,a5),a1
move.l a5,(ML_SIZE+ME_ADDR,a1)
move.l (KickMemPtr,a6),d0
move.l d0,(LN_SUCC,a1)
move.l a1,(KickMemPtr,a6)
lea (RomTag-ResidentBlock,a5),a1
move.l a1,(RT_MATCHTAG,a1)
lea (RT_SIZE,a1),a2
move.l a2,(RT_ENDSKIP,a1)
lea (TagName-ResidentBlock,a5),a2
move.l a2,(RT_NAME,a1)
move.l a5,(RT_INIT,a1)
CALL SumKickData
move.l d0,(KickCheckSum,a6)
lea (Port-ResidentBlock,a5),a1
lea (PortName-ResidentBlock,a5),a0
move.l a0,(LN_NAME,a1)
CALL AddPort
;-------------- Macro ENABLE
; subq.b #1,(IDNestCnt,a6)
; bge.b .noenable
; move.w #INTF_SETCLR|INTF_INTEN,(_custom+intena)
CALL Enable
.noenable MESSAGE <locale>,MSG_INSTALLED
bra.w Quit
;--------------
Remove
lea (PortName,pc),a1
CALL _SysBase,FindPort
tst.l d0
bne.b FoundPort
tst.b (fromWB)
bne.w WBInstall
MESSAGE <locale>,MSG_NOINSTALLED
bra.w Quit
FoundPort
movea.l d0,a4
movea.l a4,a1
CALL RemPort
;-------------- DISABLE
; move.w #INTF_INTEN,(_custom+intena)
; addq.b #1,(IDNestCnt,a6)
CALL Disable
lea (myMemList-Port,a4),a1
lea (KickMemPtr,a6),a0
.nextnode move.l (LN_SUCC,a0),d0
cmpa.l d0,a1
beq.b .foundmylist
movea.l d0,a0
bra.b .nextnode
.foundmylist move.l (LN_SUCC,a1),d0
move.l d0,(LN_SUCC,a0)
move.l (RomTagPtrs-Port+4,a4),(KickTagPtr,a6)
beq.b .noclr
bclr #7,(KickCheckSum,a6)
.noclr CALL SumKickData
move.l d0,(KickCheckSum,a6)
;-------------- ENABLE
; subq.b #1,(IDNestCnt,a6)
; bge.b .noenable
; move.w #INTF_SETCLR|INTF_INTEN,(_custom+intena)
CALL Enable
.noenable lea (ResidentBlock-Port,a4),a1
moveq #256-ResidentLen,d0
neg.b d0
CALL FreeMem
MESSAGE <locale>,MSG_REMOVED
bra.w Quit
;--------------
ResidentBlock
pushm d0-d7/a0-a6
movea.l ($4).W,a6
lea (Port,PC),a1
lea (PortName,PC),a0
move.l a0,(LN_NAME,a1)
CALL AddPort
lea (MemList,a6),a0
movea.l a0,a4
lea (ChipName,PC),a1
CALL FindName
beq.b .nofind
movea.l d0,a3
movea.l d0,a1
CALL Remove
movea.l a3,a1
movea.l a4,a0
move.b (defautpri,PC),(LN_PRI,a1)
CALL Enqueue
ori.b #LIBF_CHANGED,(LIB_FLAGS,a6)
movea.l a6,a1
CALL SumLibrary
.nofind popm
rts
RomTagPtrs dc.l 0,0
PortName cstr "ChipMemFirst.port"
TagName cstr "ChipMemFirt.tag"
ChipName cstr "chip memory"
EVEN
myMemList ds.b LN_SIZE
dc.w 1
dc.l 0
dc.l ResidentLen
Port dc.l 0
dc.l 0
dc.b NT_MSGPORT
dc.b 0
dc.l 0
dc.b 0
dc.b 0
dc.l 0
ds.b LH_SIZE
RomTag dc.w RTC_MATCHWORD
dc.l 0
dc.l 0
dc.b RTF_COLDSTART
dc.b 1
dc.b 0
dc.b -10
dc.l 0
dc.l 0
dc.l 0
defautpri dc.b 35
ResidentLen equ *-ResidentBlock
SECTION ChipMemFirst1,BSS
_DOSBase ds.l 1
_IntuitionBase ds.l 1
_SysBase ds.l 1
_LocaleBase ds.l 1
_IconBase ds.l 1
_WBMsg ds.l 1
rdargs ds.l 1
rdargs.install ds.l 1
rdargs.remove ds.l 1
rdargs.help ds.l 1
rdargs.pri ds.l 1
newpri ds.l 1
DecBuffer ds.l 8
localeinfo ds.b LocaleInfo_SIZEOF
fromWB ds.b 1
SECTION ChipMemFirst2,DATA
myRequest dc.l es_SIZEOF
dc.l 0
dc.l title
dc.l 0
dc.l format
title cstr "ChipMemFirst"
format cstr "OK"
DosName cstr "dos.library"
IntuitionName cstr "intuition.library"
LocaleName cstr "locale.library"
IconName cstr "icon.library"
CatalogName cstr "chipmemfirst.catalog"
FastRAM.txt cstr "expansion memory"
ToolPri.txt cstr "PRI"
version cstr "$VER: ChipMemFirst 1.02 (13.2.94)"
usage.msg dc.b "Usage: ChipMemFirst "
template dc.b "I=INSTALL/S,"
dc.b "R=REMOVE/S,"
dc.b "?=HELP/S,"
dc.b "PRI/N"
dc.b 10,10,0
hello.msg dc.b 10
dc.b '\C1;33m'
dc.b "ChipMemFirt © Pat (13/02/94)"
dc.b '\C0;39m',10,10,0
SECTION Localized,DATA
CatCompBlock
DC.L $0
DC.W $20
DC.B 'Can',39,'t find intuition.library.',10,10,$00
DC.L $1
DC.W $1A
DC.B 'Can',39,'t find dos.library.',10,10,$00
DC.L $2
DC.W $1C
DC.B 'Can',39,'t find icon.library.',10,10,$00,$00
DC.L $3
DC.W $22
DC.B 'ChipMemFist is already running.',10,10,$00
DC.L $4
DC.W $18
DC.B 'No memory for romtag.',10,10,$00
DC.L $5
DC.W $28
DC.B 'ChipMemFirst is ready, reboot please.',10,10,$00
DC.L $6
DC.W $22
DC.B 'ChipMemfirst is not installed.',10,10,$00,$00
DC.L $7
DC.W $28
DC.B 'ChipMemFirst removed, reboot please.'
DC.B 10,10,$00,$00
DC.L $8
DC.W $16
DC.B 'Sorry, no fast mem.',10,10,$00
DC.L $9
DC.W $32
DC.B 'Your prioritie is not a valide decimal number.'
DC.B 10,10,' ',$00
DC.L $A
DC.W $34
DC.B 'Your prioritie is lower than fast ram prioritie.'
DC.B 10,10,' ',$00,$00
END
Directives: MC68000 -> type processeur/instructions
EXOBJ -> executable
OBJFILE -> nom du fichier généré lors de l'assemblage.
<-> OUTPUT
STRICT -> utilise la syntaxe précise des instructions.
exemples: sub.l a0,a0 -> suba.l a0,a0
move.l d1,a1 -> movea.l d1,a1
cmp.w #2,d0 -> cmpi.w #2,d0
Le contaire étant le mode RELAX.
NEWSYNTAX -> utilise la nouvelle syntaxe definie par
MOTOROLA pour l'ensemble de la gamme 68000.
exemples: move.l $4.w,a6 -> movea.l ($4).w,a6
move.l d0,_GfxBase -> move.l d0,(_GfxBase)
move.l d0,8(a2) -> move.l d0,(8,a2)
beq.s -> beq.b
bra.l -> bra.w
Le contraire étant OLDSYNTAX.
MULTIPASS -> passes d'optimisation.
INCPATH <-> INCDIR
MACFILE <-> INCLUDE
ESCAPESTR -> permet d'intoduire des séquences d'échappement
dans une chaine de caractères.
DC.B "chaine\N",0 -> DC.B "chaine",10,0
SETRL -> définie une liste provisoire de registres.
CSTR "chaine" -> DC.B "chaine",0
COMMENT -> commentaire sans * et ;.
VERBOSEOPTIM -> phase d'optimisation dans le code source.
Utilisation: pour des demos ou jeux qui supposent que vous avez que de
la chip ram.
Mais ATTENTION, la chip ram est très précieuse car non expansible.
A par celles avec l'attribut MEMF_FAST, toutes les allocations
se font en chip ram.
De plus les accès en chip ram pour un A4000/040 sont très lents
(Par rapport à un A1200 de base, un A4000/040 est 30 à 40 % plus lent lors
des accès en chip ram).
Par conséquent, ChipMemFirst est à utiliser à bon escient.
ChipMemFirst fonctionne à partir de l'AmigaDos 2.1.
chipmemfirst.catalog est à installé dans PROGDIR:catalogs/français ou
dans LOCALE:catalogs/français.
A partir du CLI, la syntaxe de ChipMemFirst est la suivante:
ChipMemFirst i=install [pri]
ChipMemFirst ?=help
ChipMemFirst r=remove
A partir du Workbench, un premier double-clic installe le code résident.
Un tooltype PRI=valeur peut exister dans ChipMemFirst.info.
Un second double-click, enlève ce code résident.
ChipMemFirst est librement distribuable mais sans une seule modification
et dans son intégralité.
liste des fichiers fournis: ChipMemFirst
ChipMemfirst.info
ChipMemfirst.asm
mystartup.i
libmacs.i
chipmemfirst.cd
empty.ct
français.ct
chipmemfirst.catalog
CMF_strings.asm
Contacts: RAULT Patrice
1, rue Gabriel Péri
29200 BREST
FRANCE